

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>CephFS 管理命令 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="多套 Ceph 文件系统" href="../multifs/" />
    <link rel="prev" title="创建 Ceph 文件系统" href="../createfs/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 文件系统</a></li>
      <li class="breadcrumb-item active">CephFS 管理命令</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/cephfs/administration.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id4">管理</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../createfs/"> 创建 CephFS 文件系统</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> 管理命令</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">文件系统管理</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id2">可配置选项</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">最大文件尺寸以及性能</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">关闭集群</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id5">快速关闭集群以进行删除或灾难恢复</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id6">守护进程管理</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id7">客户端必须具备的功能</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id8">全局配置选项</a></li>
<li class="toctree-l4"><a class="reference internal" href="#advanced-cephfs-admin-settings">高级选项</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../multifs/"> 创建多个文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../add-remove-mds/"> 配备、增加、删除 MDS</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/">术语</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds">MDS 守护进程的引用</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#id3">故障切换的管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#standby-replay">热备（ standby-replay ）的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../standby/#mds-join-fs">配置 MDS 与文件系统的亲和性</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cache-configuration/"> MDS 缓存配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mds-config-ref/"> MDS 配置选项</a></li>
<li class="toctree-l3"><a class="reference internal" href="../../man/8/ceph-mds/"> ceph-mds 手册页</a></li>
<li class="toctree-l3"><a class="reference internal" href="../nfs/"> 通过 NFS 导出</a></li>
<li class="toctree-l3"><a class="reference internal" href="../app-best-practices/"> 应用最佳实践</a></li>
<li class="toctree-l3"><a class="reference internal" href="../fs-volumes/"> FS 卷和子卷</a></li>
<li class="toctree-l3"><a class="reference internal" href="../quota/"> CephFS 配额管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../health-messages/"> 健康消息</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upgrading/">升级 MDS 集群</a></li>
<li class="toctree-l3"><a class="reference internal" href="../upgrading/#firefly-jewel">升级比 Firefly 老的文件系统，需过 Jewel 这个槛</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-top/"> CephFS Top 工具</a></li>
<li class="toctree-l3"><a class="reference internal" href="../snap-schedule/"> 定时快照</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-mirroring/"> CephFS 快照镜像</a></li>
<li class="toctree-l3"><a class="reference internal" href="../purge-queue/"> 清理队列</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id5">挂载 CephFS</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id6">CephFS 内幕</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="cephfs">
<span id="cephfs-administration"></span><h1>CephFS 管理命令<a class="headerlink" href="#cephfs" title="Permalink to this heading"></a></h1>
<section id="id1">
<h2>文件系统管理<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>文件系统、元数据存储池、和数据存储池的名字只能由这些字符 [a-zA-Z0-9_-.] 组成。</p>
</div>
<p>这些命令适用于 Ceph 集群的 CephFS 文件系统。注意，默认情况下，只允许一个文件系统；执行 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">fs</span> <span class="pre">flag</span> <span class="pre">set</span> <span class="pre">enable_multiple</span> <span class="pre">true</span></code>
后才允许创建多个文件系统。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">new</span> <span class="o">&lt;</span><span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">metadata</span> <span class="n">pool</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">data</span> <span class="n">pool</span> <span class="n">name</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>该命令可创建一个新文件系统，文件系统名称和元数据存储池名称如上所述。
指定的数据存储池是默认数据存储池，一旦设置就不能更改。
每个文件系统都有自己的一套 MDS 守护进程，分别管理各个 rank ，
因此要确保有足够的备用守护进程来容纳新文件系统。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">ls</span>
</pre></div>
</div>
<p>按名字罗列所有文件系统。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">lsflags</span> <span class="o">&lt;</span><span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>罗列一个文件系统上设置的所有标志。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">dump</span> <span class="p">[</span><span class="n">epoch</span><span class="p">]</span>
</pre></div>
</div>
<p>此操作将转储指定时间结（默认：当前的）的 FSMap ，
其中包括所有的文件系统设置、 MDS 守护进程及其持有的 rank ，
以及备用 MDS 守护进程列表。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">rm</span> <span class="o">&lt;</span><span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">--</span><span class="n">yes</span><span class="o">-</span><span class="n">i</span><span class="o">-</span><span class="n">really</span><span class="o">-</span><span class="n">mean</span><span class="o">-</span><span class="n">it</span><span class="p">]</span>
</pre></div>
</div>
<p>销毁 CephFS 文件系统。此命令会从 FSMap 中抹去有关文件系统状态的信息。
不会触及元数据存储池和数据存储池，
它们需要分开销毁。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">get</span> <span class="o">&lt;</span><span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>获取指定文件系统的信息，包括配置信息和各 rank 。
这是 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">fs</span> <span class="pre">dump</span></code> 命令中相同信息的子集。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">var</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">val</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>更改文件系统的配置。这些设置选项只针对指定的文件系统，
不会影响其他文件系统。集群不健康时，
只有更改 <code class="docutils literal notranslate"><span class="pre">max_mds</span></code> 才需要确认标记。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>当集群不健康时，修改 FS 配置变量 <code class="docutils literal notranslate"><span class="pre">max_mds</span></code>
必须加上确认标志（ <code class="docutils literal notranslate"><span class="pre">--yes-i-really-mean-it</span></code> ）。
这个额外的预防措施是告诉用户，
在故障排除或恢复过程中修改 <code class="docutils literal notranslate"><span class="pre">max_mds</span></code> 可能于事无补。
相反，它可能会进一步破坏集群的稳定性。</p>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">add_data_pool</span> <span class="o">&lt;</span><span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">pool</span> <span class="n">name</span><span class="o">/</span><span class="nb">id</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>给文件系统增加一个数据存储池。此存储池可用于文件布局，
作为存储文件数据的替代位置。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">rm_data_pool</span> <span class="o">&lt;</span><span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">pool</span> <span class="n">name</span><span class="o">/</span><span class="nb">id</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>此命令从文件系统的数据存储池列表中删除指定的存储池。
如果有文件伸展到了被删除的数据存储池，
这部分文件数据将不可用。无法删除默认数据存储池
（创建文件系统时的）。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">rename</span> <span class="o">&lt;</span><span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">new</span> <span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">--</span><span class="n">yes</span><span class="o">-</span><span class="n">i</span><span class="o">-</span><span class="n">really</span><span class="o">-</span><span class="n">mean</span><span class="o">-</span><span class="n">it</span><span class="p">]</span>
</pre></div>
</div>
<p>重命名一个 Ceph 文件系统。这个操作同时会把文件系统的数据存储池和元数据存储池上的应用标签（ application tag ）更改为新的文件系统名称。
授权给旧文件系统名字的 CephX ID 需要重新授权到新名字。
正在使用这些 ID 的客户端们正在进行的所有操作都可能会中断。
文件系统上的镜像应该禁用掉。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">swap</span> <span class="o">&lt;</span><span class="n">fs1</span><span class="o">-</span><span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">fs1_id</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">fs2</span><span class="o">-</span><span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">fs2_id</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">--</span><span class="n">swap</span><span class="o">-</span><span class="n">fscids</span><span class="o">=</span><span class="n">yes</span><span class="o">|</span><span class="n">no</span><span class="p">]</span> <span class="p">[</span><span class="o">--</span><span class="n">yes</span><span class="o">-</span><span class="n">i</span><span class="o">-</span><span class="n">really</span><span class="o">-</span><span class="n">mean</span><span class="o">-</span><span class="n">it</span><span class="p">]</span>
</pre></div>
</div>
<p>交换两个 Ceph 文件系统的名称，并相应更新两个文件系统所有存储池上的应用程序标签。
某些工具跟踪的是文件系统 FSCID ，而不是名字，
可能会因为这一操作而错乱。因此，
系统提供了 <code class="docutils literal notranslate"><span class="pre">--swap-fscids</span></code> 强制选项，
用以决定是否必须交换 FSCID 。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>FSCID 表示文件系统集群 ID （File System Cluster ID ）。</p>
</div>
<p>在交换之前，应禁用两个 CephFS 上的镜像功能
（因为 cephfs-mirror 守护进程内部使用的是 fscid ，
在它运行时更改 fscid 可能会导致不可预知的行为），
两个 CephFS 都应处于离线状态，并且必须为两个 CephFS
设置文件系统标志 <code class="docutils literal notranslate"><span class="pre">refuse_client_sessions</span></code> 。</p>
<p>这个 API 的功能是为了方便灾难恢复，
在灾难恢复时，从先前的文件系统重建的新文件系统准备好了，
可以随时接替可能受损的文件系统。
操作员可以使用交换操作来代替两次 <code class="docutils literal notranslate"><span class="pre">fs</span> <span class="pre">rename</span></code> 重命名操作，
这样就不会出现通过名字调用的主（或生产环境）文件系统不存在的 FSMap 时间结。
当 Ceph 被（ Rook ）这样的自动化存储操作员监控时，
这一点非常重要，因为这些操作员会尝试持续调节存储系统。
一旦发现文件系统不存在，操作员就会尝试重新创建文件系统。</p>
<p>交换后，如果现有的挂载要“跟着”旧文件系统到它的新名字，
那么可能需要重新授权 CephX 凭据。一般来说，
为了实现灾难恢复，现有挂载最好继续使用相同的文件系统名字。
所有已经挂载的 CephFS 文件系统都必须重新挂载。
还存在的未刷入操作将丢失。当判断出其中一个已交换的文件系统已经准备好供客户端使用时，运行：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">fs</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">fs</span><span class="o">&gt;</span> <span class="n">joinable</span> <span class="n">true</span>
<span class="n">ceph</span> <span class="n">fs</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">fs</span><span class="o">&gt;</span> <span class="n">refuse_client_sessions</span> <span class="n">false</span>
</pre></div>
</div>
<p>记住，如果正在做灾难恢复交换，其中一个被交换的文件系统可以保持离线，以便将来进行分析。</p>
</section>
<section id="id2">
<h2>可配置选项<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">fs</span> <span class="n">name</span><span class="o">&gt;</span> <span class="n">max_file_size</span> <span class="o">&lt;</span><span class="n">size</span> <span class="ow">in</span> <span class="nb">bytes</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>CephFS 允许的最大文件尺寸是可以配置的，默认是 1TB 。如果你想在
CephFS 里存储大文件，也许得把这个限量设置得高些。它是个 64 位的字段。</p>
<p>把 <code class="docutils literal notranslate"><span class="pre">max_file_size</span></code> 设置为 0 并不意味着取消这个限量，
而是限制客户端只能创建空文件。</p>
</section>
<section id="id3">
<h2>最大文件尺寸以及性能<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>在追加到文件、或设置其尺寸时， CephFS 将确保不会超过最大文件尺寸限量；但不会影响（数据）是怎样存储的。</p>
<p>有用户创建了一个硕大的文件时（没必要写入什么数据），
某些操作（像删除）会让 MDS 不得不做大量操作，
去检查此文件的尺寸范围内是否有本应存在
（据文件尺寸计算出的）、实际上却不存在的 RADOS 对象。</p>
<p><code class="docutils literal notranslate"><span class="pre">max_file_size</span></code> 选项可防止用户创建巨型文件，如 EB 级的文件，导致在遇到类似查询状态或删除操作时产生无谓的 MDS 负载。</p>
</section>
<section id="id4">
<h2>关闭集群<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<p>关闭一个 CephFS 集群需要设置 down 标志：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">fs_name</span><span class="o">&gt;</span> <span class="n">down</span> <span class="n">true</span>
</pre></div>
</div>
<p>让集群重新上线：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">fs_name</span><span class="o">&gt;</span> <span class="n">down</span> <span class="n">false</span>
</pre></div>
</div>
<p>此命令还会恢复 max_mds 以前的值。
MDS 守护进程离线时，会将日志刷入元数据存储池，并停止所有客户端 I/O 。</p>
</section>
<section id="id5">
<h2>快速关闭集群以进行删除或灾难恢复<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h2>
<p>要快速删除文件系统（用于测试）或者快速关闭文件系统和
MDS 守护进程，可以用 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">fs</span> <span class="pre">fail</span></code> 命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">fs</span> <span class="n">fail</span> <span class="o">&lt;</span><span class="n">fs_name</span><span class="o">&gt;</span> <span class="p">{</span><span class="o">--</span><span class="n">yes</span><span class="o">-</span><span class="n">i</span><span class="o">-</span><span class="n">really</span><span class="o">-</span><span class="n">mean</span><span class="o">-</span><span class="n">it</span><span class="p">}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>注意，确认标记是可选的，
因为只有当 MDS 处于活动状态而且有健康警告
MDS_TRIM 或 MDS_CACHE_OVERSIZED 时才需要。</p>
</div>
<p>此命令会设置一个文件系统标志，
以防止备用机激活这个文件系统（ <code class="docutils literal notranslate"><span class="pre">joinable</span></code> 标志）。</p>
<p>也可以通过以下操作手动完成此过程：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">fs_name</span><span class="o">&gt;</span> <span class="n">joinable</span> <span class="n">false</span>
</pre></div>
</div>
<p>然后，操作员就可以让所有 rank 失效，这将导致相关的
MDS 守护进程重生为热备。文件系统将处于降级状态。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># For all ranks, 0-N:</span>
<span class="n">mds</span> <span class="n">fail</span> <span class="o">&lt;</span><span class="n">fs_name</span><span class="o">&gt;</span><span class="p">:</span><span class="o">&lt;</span><span class="n">n</span><span class="o">&gt;</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>注意，确认标记是可选的，
因为只有当 MDS 处于活动状态而且有健康警告
MDS_TRIM 或 MDS_CACHE_OVERSIZED 时才需要。</p>
</div>
<p>一旦所有 rank 都处于不活动状态，文件系统就可以删除或者留在这个状态以用于其他目的（或许灾难恢复）。</p>
<p>要恢复集群，只需设置 joinable 标志即可：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">fs_name</span><span class="o">&gt;</span> <span class="n">joinable</span> <span class="n">true</span>
</pre></div>
</div>
</section>
<section id="id6">
<h2>守护进程管理<a class="headerlink" href="#id6" title="Permalink to this heading"></a></h2>
<p>大多数可操纵 MDS 的命令都需要一个 <code class="docutils literal notranslate"><span class="pre">&lt;role&gt;</span></code> 参数，
它必须是以下三种格式之一：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;</span><span class="n">fs_name</span><span class="o">&gt;</span><span class="p">:</span><span class="o">&lt;</span><span class="n">rank</span><span class="o">&gt;</span>
<span class="o">&lt;</span><span class="n">fs_id</span><span class="o">&gt;</span><span class="p">:</span><span class="o">&lt;</span><span class="n">rank</span><span class="o">&gt;</span>
<span class="o">&lt;</span><span class="n">rank</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>可操纵 MDS 守护进程的命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">mds</span> <span class="n">fail</span> <span class="o">&lt;</span><span class="n">gid</span><span class="o">/</span><span class="n">name</span><span class="o">/</span><span class="n">role</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>把一个 MDS 守护进程标记为已失效。假如一个 MDS 守护进程在
<code class="docutils literal notranslate"><span class="pre">mds_beacon_grace</span></code> 秒内都没向监视器发送一条消息，
这个操作就等价于集群自己的操作。如果此守护进程之前是活跃的，
而且有可用的备机，用命令 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">mds</span> <span class="pre">fail</span></code> 将迫使业务转移到备机。</p>
<p>如果此 MDS 守护进程事实上仍在运行，那么执行 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">mds</span> <span class="pre">fail</span></code>
将使之重启；如果它之前是活跃的、并且还有可用的备机，
那么这个“已失效”的守护进程回来后将作为备机。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.&lt;</span><span class="n">daemon</span> <span class="n">name</span><span class="o">&gt;</span> <span class="n">command</span> <span class="o">...</span>
</pre></div>
</div>
<p>向 MDS 守护进程发出一个命令，指定 <code class="docutils literal notranslate"><span class="pre">mds.*</span></code> 可向所有守护进程发送命令。用 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">tell</span> <span class="pre">mds.*</span> <span class="pre">help</span></code> 命令获取所有可用命令。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">mds</span> <span class="n">metadata</span> <span class="o">&lt;</span><span class="n">gid</span><span class="o">/</span><span class="n">name</span><span class="o">/</span><span class="n">role</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>获取指定 MDS （监视器知道它）的元数据。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">mds</span> <span class="n">repaired</span> <span class="o">&lt;</span><span class="n">role</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>把文件系统 rank 标记为已修复。这里不像名字说明的那样，这个命令不会更改 MDS ，它操纵的是先前被标记为已损坏的文件系统 rank 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">mds</span> <span class="n">last</span><span class="o">-</span><span class="n">seen</span> <span class="o">&lt;</span><span class="n">name</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>了解名字是 <code class="docutils literal notranslate"><span class="pre">name</span></code> 的 MDS 上次出现在 FSMap 中的时间。
JSON 格式的输出包括 MDS 最后出现的时间结。
历史信息受到以下 <code class="docutils literal notranslate"><span class="pre">mon</span></code> 配置选项的限制：</p>
<dl class="std confval">
<dt class="sig sig-object std" id="confval-mon_fsmap_prune_threshold">
<span class="sig-name descname"><span class="pre">mon_fsmap_prune_threshold</span></span><a class="headerlink" href="#confval-mon_fsmap_prune_threshold" title="Permalink to this definition"></a></dt>
<dd><blockquote>
<div><p>The monitors keep historical fsmaps in memory to optimize asking when
an MDS daemon was last seen in the FSMap. This option controls how far
back in time the monitors will look.</p>
<dl class="field-list simple">
<dt class="field-odd">type<span class="colon">:</span></dt>
<dd class="field-odd"><p><code class="docutils literal notranslate"><span class="pre">secs</span></code></p>
</dd>
<dt class="field-even">default<span class="colon">:</span></dt>
<dd class="field-even"><p><code class="docutils literal notranslate"><span class="pre">300</span></code></p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

</section>
<section id="id7">
<h2>客户端必须具备的功能<a class="headerlink" href="#id7" title="Permalink to this heading"></a></h2>
<p>有时需要设置门槛，客户端必须支持哪些功能才能与 CephFS 通信。
没有这些功能的客户端可能会干扰其他客户端或出现意料之外的行为。
或者，您可能希望必须具备较新的功能，
以防止较旧且可能存在漏洞的客户端连接。</p>
<p>修改一个文件系统，要求客户端必须具备哪些功能的命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">required_client_features</span> <span class="o">&lt;</span><span class="n">fs</span> <span class="n">name</span><span class="o">&gt;</span> <span class="n">add</span> <span class="n">reply_encoding</span>
<span class="n">fs</span> <span class="n">required_client_features</span> <span class="o">&lt;</span><span class="n">fs</span> <span class="n">name</span><span class="o">&gt;</span> <span class="n">rm</span> <span class="n">reply_encoding</span>
</pre></div>
</div>
<p>罗列所有的 CephFS 功能：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">fs</span> <span class="n">feature</span> <span class="n">ls</span>
</pre></div>
</div>
<p>缺少新增加功能的客户端将被自动驱逐。</p>
<p>以下是当前的 CephFS 功能及其首次出现的版本：</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>功能</p></th>
<th class="head"><p>Ceph 版本</p></th>
<th class="head"><p>上游内核</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>jewel</p></td>
<td><p>jewel</p></td>
<td><p>4.5</p></td>
</tr>
<tr class="row-odd"><td><p>kraken</p></td>
<td><p>kraken</p></td>
<td><p>4.13</p></td>
</tr>
<tr class="row-even"><td><p>luminous</p></td>
<td><p>luminous</p></td>
<td><p>4.13</p></td>
</tr>
<tr class="row-odd"><td><p>mimic</p></td>
<td><p>mimic</p></td>
<td><p>4.19</p></td>
</tr>
<tr class="row-even"><td><p>reply_encoding</p></td>
<td><p>nautilus</p></td>
<td><p>5.1</p></td>
</tr>
<tr class="row-odd"><td><p>reclaim_client</p></td>
<td><p>nautilus</p></td>
<td><p>N/A</p></td>
</tr>
<tr class="row-even"><td><p>lazy_caps_wanted</p></td>
<td><p>nautilus</p></td>
<td><p>5.1</p></td>
</tr>
<tr class="row-odd"><td><p>multi_reconnect</p></td>
<td><p>nautilus</p></td>
<td><p>5.1</p></td>
</tr>
<tr class="row-even"><td><p>deleg_ino</p></td>
<td><p>octopus</p></td>
<td><p>5.6</p></td>
</tr>
<tr class="row-odd"><td><p>metric_collect</p></td>
<td><p>pacific</p></td>
<td><p>N/A</p></td>
</tr>
<tr class="row-even"><td><p>alternate_name</p></td>
<td><p>pacific</p></td>
<td><p>6.5</p></td>
</tr>
<tr class="row-odd"><td><p>notify_session_state</p></td>
<td><p>quincy</p></td>
<td><p>5.19</p></td>
</tr>
<tr class="row-even"><td><p>op_getvxattr</p></td>
<td><p>quincy</p></td>
<td><p>6.0</p></td>
</tr>
<tr class="row-odd"><td><p>32bits_retry_fwd</p></td>
<td><p>reef</p></td>
<td><p>6.6</p></td>
</tr>
<tr class="row-even"><td><p>new_snaprealm_info</p></td>
<td><p>reef</p></td>
<td><p>UNKNOWN</p></td>
</tr>
<tr class="row-odd"><td><p>has_owner_uidgid</p></td>
<td><p>reef</p></td>
<td><p>6.6</p></td>
</tr>
<tr class="row-even"><td><p>client_mds_auth_caps</p></td>
<td><p>squid+bp</p></td>
<td><p>PLANNED</p></td>
</tr>
</tbody>
</table>
<p>CephFS 功能描述</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">reply_encoding</span>
</pre></div>
</div>
<p>如果客户端支持此功能，那么 MDS 会将请求回复编码为可扩展格式。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">reclaim_client</span>
</pre></div>
</div>
<p>MDS 允许新客户端承袭另一个（已死亡）客户端的状态。
NFS-Ganesha 使用了这一功能。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">lazy_caps_wanted</span>
</pre></div>
</div>
<p>当落伍的客户端恢复时，如果客户端支持此功能，
那么 mds 只需要重新发放它明确要求的能力即可。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">multi_reconnect</span>
</pre></div>
</div>
<p>当 mds 故障切换时，客户端会向 mds 发送重连消息，
以重建缓存状态。如果 MDS 支持此功能，
客户端就可以将大的重新连接信息分成多条。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">deleg_ino</span>
</pre></div>
</div>
<p>如果客户端支持此功能， MDS 就把 inode 号委托（ delegate ）给客户端。
拥有委托的 inode 号是先决条件，而后客户端才能异步地创建文件。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">metric_collect</span>
</pre></div>
</div>
<p>如果 MDS 支持性能指标功能，客户端可以发给它。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">alternate_name</span>
</pre></div>
</div>
<p>客户端可以设置并理解目录的“别名（ alternate names ）”。
此功能用于支持加密的文件名。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">client_mds_auth_caps</span>
</pre></div>
</div>
<p>要在客户端的 <code class="docutils literal notranslate"><span class="pre">mds</span></code> caps 中有效执行 <code class="docutils literal notranslate"><span class="pre">root_squash</span></code> ，
客户端必须了解它正在执行 <code class="docutils literal notranslate"><span class="pre">root_squash</span></code> 和其他 cap 元数据。
没有此功能的客户端存在风险，会丢弃文件的更新。
建议设置此功能位。</p>
</section>
<section id="id8">
<h2>全局配置选项<a class="headerlink" href="#id8" title="Permalink to this heading"></a></h2>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">fs</span> <span class="n">flag</span> <span class="nb">set</span> <span class="o">&lt;</span><span class="n">flag</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">flag</span> <span class="n">val</span><span class="o">&gt;</span> <span class="p">[</span><span class="o">&lt;</span><span class="n">confirmation</span> <span class="n">string</span><span class="o">&gt;</span><span class="p">]</span>
</pre></div>
</div>
<p>设置全局的 CephFS 标记（即不是特定于某个文件系统的）。
当前，仅有的标记是 enable_multiple ，启用它就可以支持多个
CephFS 文件系统。</p>
<p>有些标志会强迫你用 <code class="docutils literal notranslate"><span class="pre">--yes-i-really-mean-it</span></code> 或者类似的语句
（执行时会提示）来确认你的意图。运行这类命令时要三思而后行，
它们通常用于提示非常危险的动作。</p>
</section>
<section id="advanced-cephfs-admin-settings">
<span id="id9"></span><h2>高级选项<a class="headerlink" href="#advanced-cephfs-admin-settings" title="Permalink to this heading"></a></h2>
<p>以下这些命令在常规操作中用不到，在遇到异常时才需要。
这些命令若使用不当会产生严重问题，
甚至会导致文件系统无法访问。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">mds</span> <span class="n">rmfailed</span>
</pre></div>
</div>
<p>从失效集合中删除一个 rank 。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">fs</span> <span class="n">reset</span> <span class="o">&lt;</span><span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span>
</pre></div>
</div>
<p>此命令可把文件系统状态（除名字和存储池以外的）重置为默认值。所有非 0 rank 都会保存在已停止集里面。</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">fs</span> <span class="n">new</span> <span class="o">&lt;</span><span class="n">file</span> <span class="n">system</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">metadata</span> <span class="n">pool</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">&lt;</span><span class="n">data</span> <span class="n">pool</span> <span class="n">name</span><span class="o">&gt;</span> <span class="o">--</span><span class="n">fscid</span> <span class="o">&lt;</span><span class="n">fscid</span><span class="o">&gt;</span> <span class="o">--</span><span class="n">force</span>
</pre></div>
</div>
<p>此命令将创建一个具有指定 <strong>fscid</strong> （文件系统集群 ID ）的文件系统。
当应用程序希望文件系统的 ID 在恢复后仍能保持稳定时，
你可能想要这样做，例如在监视器数据库丢失并重建后。
因此，文件系统 ID 并不总是随着较新的文件系统出现而不断增加。</p>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../createfs/" class="btn btn-neutral float-left" title="创建 Ceph 文件系统" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../multifs/" class="btn btn-neutral float-right" title="多套 Ceph 文件系统" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>